package com.hy.controller;

import com.hy.bean.Classify;
import com.hy.service.ClassifyService;
import com.hy.service.impl.ClassifyServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Classify)表控制层
 *
 * @author makejava
 * @since 2024-04-29 11:08:28
 */
@RestController
@RequestMapping("classify")
public class ClassifyController {
    /**
     * 服务对象
     */

    private ClassifyService classifyService = new ClassifyServiceImpl();

    @RequestMapping("select")
    public ResponseEntity<List<Classify>> queryAll() throws Exception {
        return ResponseEntity.ok(this.classifyService.queryAll());
    }

    /**
     * 新增数据
     *
     * @param classify 实体
     * @return 新增结果
     */
    @RequestMapping("insert")
    public ResponseEntity<Classify> add(Classify classify) throws Exception {
        return ResponseEntity.ok(this.classifyService.insert(classify));
    }

    /**
     * 编辑数据
     *
     * @param classify 实体
     * @return 编辑结果
     */
    @RequestMapping("update")
    public ResponseEntity<Classify> edit(Classify classify) throws Exception {
        return ResponseEntity.ok(this.classifyService.update(classify));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @RequestMapping("delete")
    public ResponseEntity<Boolean> deleteById(int id) throws Exception {
        return ResponseEntity.ok(this.classifyService.deleteById(id));
    }

}

